<template>
  <div>
    <el-tag
      v-for="cat in categories"
      :key="cat.id"
      @click="selectCategory(cat.category_name)"
      class="mr-1"
      >{{ cat.category_name }}</el-tag
    >
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import api from '../api'

const categories = ref([])

onMounted(async () => {
  const res = await api.get('/categories')
  categories.value = res.data.result
})

const selectCategory = (name) => {
  // TODO: 触发父组件筛选
}
</script>
